package com.hualan.sfzy.service.mind.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.entity.mind.MindTest;
import com.hualan.sfzy.mapper.mind.MindTestMapper;
import com.hualan.sfzy.service.BaseServiceImp;
import com.hualan.sfzy.service.mind.MindTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MindTestServiceImpl extends BaseServiceImp<MindTest> implements MindTestService{
    @Autowired
    private MindTestMapper mindTestMapper;

    @Override
    public Map<String, Object> findByPage(Integer pageNum, Integer pageSize, MindTest mindTest) {
        PageHelper.startPage(pageNum, pageSize);
        List<MindTest> list = mindTestMapper.select(mindTest);
        PageInfo<MindTest> pageInfo = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put(CommonConstant.PAGE_LIST, list);
        map.put(CommonConstant.PAGE_TOTAL, pageInfo.getPages());
        map.put(CommonConstant.TOTAL, pageInfo.getTotal());
        return map;
    }
}